package com.easyadmin.modules.stock.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easyadmin.common.web.domain.request.PageDomain;
import com.easyadmin.modules.stock.domain.SysStockSpotRecordEntity;
import com.easyadmin.modules.stock.mapper.SysStockSpotRecordDao;
import com.easyadmin.modules.stock.service.SysStockSpotRecordServer;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service("sysStockSpotRecordServer")
public class SysStockSpotRecordServerImpl extends ServiceImpl<SysStockSpotRecordDao,SysStockSpotRecordEntity>
        implements SysStockSpotRecordServer {

    @Autowired
    SysStockSpotRecordDao sysStockSpotRecordDao;

    @Override
    public PageInfo<SysStockSpotRecordEntity> queryPage(SysStockSpotRecordEntity sysStockSpotRecordEntity,
                                                        PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<SysStockSpotRecordEntity> data =sysStockSpotRecordDao.selectList(new QueryWrapper<>());
        return new PageInfo<>(data);
    }

    @Override
    public Boolean remove(String id) {
        sysStockSpotRecordDao.deleteById(Integer.valueOf(id));
        return true;
    }

    @Override
    public boolean update(SysStockSpotRecordEntity sysStockSpotRecordEntity) {
        Integer result = sysStockSpotRecordDao.updateById(sysStockSpotRecordEntity);
        return result > 0;
    }

    @Override
    public boolean batchRemove(String[] ids) {
        for(String  id:ids){
            sysStockSpotRecordDao.deleteById(id);
        }
        return true;
    }
}
